package cn.cai.service.impl;

import cn.cai.mapper.UserMapper;
import cn.cai.pojo.User;
import cn.cai.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 用户登录逻辑的实现
     * @param username
     * @return
     */
    @Override
    public User login(String username) {
        return userMapper.selectUserByUserName(username);
    }

    @Override
    public List<String> findRolesByUser(User user) {
        return userMapper.selectRolesByUserId(user.getId());
    }

    @Override
    public List<String> findResourcesByUser(User user) {
        return userMapper.selectResourcesByUserId(user.getId());
    }

    @Override
    public User loginBy(String username) {
        return userMapper.selectUserByUserName(username);
    }
}
